#!/bin/sh
# 商品索引：搜索建议suggest，分词搜索content(title,catName,brandName,areaName)
curl -XDELETE 'http://localhost:9200/mall_item'
curl -XPUT 'http://localhost:9200/mall_item'
curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/mall_item/_mapping?pretty' -d '{
        "properties" : {
                "id" : { "type" : "long" },
                "shopId" : { "type" : "long" },
                "catId" : { "type" : "keyword" },
                "catName" : { "type" : "keyword" , "copy_to": [ "content", "suggest" ] },
                "title" : { "type" : "keyword" , "copy_to": [ "content", "suggest" ] },
                "imgUrl" : { "type" : "keyword", "index": false },
                "brandId" : { "type" : "long" },
                "brandName" : { "type" : "keyword", "copy_to": [ "content", "suggest" ] },
                "priceType" : { "type" : "keyword" },
                "marketPrice" : { "type" : "double", "index": false },
                "price" : { "type" : "double" },
                "unit" : { "type" : "keyword", "index": false },
                "minNum" : { "type" : "keyword", "index": false },
                "areaId" : { "type" : "keyword" },
                "areaName" : { "type" : "keyword" , "copy_to": "content" },
                "provinceName" : { "type" : "keyword" , "copy_to": "content"},
                "putTime" : { "type" : "date" },
                "num" : { "type" : "long" },
                "sellNum" : { "type" : "long" },
                "freightTime" : { "type" : "long" },
                "attrs" : { "type" : "keyword" },
                "content" : { "type" : "text", "analyzer": "ik_max_word" },
                "suggest" : { "type" : "completion", "analyzer": "ik_max_word" }
        }
}'
curl -H 'Content-Type: application/json' -XPUT 'http://localhost:9200/mall_item/_settings' -d '{
        "index" : {  "max_result_window" : 1000000 }
}'